package com.qi.demo.Service;

import com.qi.demo.model.Booklistmodel;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Random;

@RestController
@RequestMapping("/book")
public class BookController {
    @RequestMapping("/r1")
    public ArrayList<Booklistmodel> getList(){
        ArrayList<Booklistmodel> list=mockData();
        return list;

    }

    private ArrayList<Booklistmodel> mockData() {
        ArrayList<Booklistmodel> list=new ArrayList<>();
        for (int i = 1; i <= 15; i++) {
            Booklistmodel book=new Booklistmodel();
            book.setBookName("book"+i);
            book.setBookId(i);
            book.setNum(i);
            book.setPublish("人民出版社");
            book.setPrice(new BigDecimal((new Random().nextInt(100))));
            book.setAuthor("张三");
            book.setStatus(i%2);
            list.add(book);


        }
        return list;
    }
}
